public with sharing class UIDemoController extends PageControllerBase {
     
      public ApexPages.StandardController standardCon { get; set; }
      public String fieldName                         { get; set; }

      public UIDemoController(ApexPages.StandardController controller) {
            standardCon = controller;
            this.myObject = controller.getRecord(); 
            //insertDummyLookupRecords();        
      }
       
      // First we save the values from the Enhanced Component controllers, then whatever standard fields there are.
      // If you are using standard fields in addition to enhanced components, fields required by the API should always be in the first position 
      
     public PageReference save()  
     {
        ecSave();
        standardCon.save();

        return null;
     }
        
     public void insertDummyLookupRecords() {
        /*
             List<TestLookupObject__c> tlos = new List <TestLookupObject__c>();
        
             TestLookupObject__c tlo = new TestLookupObject__c(); tlo.name = 'Adélie penguin - Pygoscelis adeliae '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'African elephant - Loxodonta africana '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'American beaver - Castor canadensis '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'American bison - Bison bison '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'American black bear - Ursus americanus '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'American moose - Alces americanus '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Amphibians - Class Amphibia '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Amphisbaenians, Lizards, and Snakes - Order Squamata '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Amur leopard - Panthera pardus orientalis '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Animals - Kingdom Animalia '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Arctic wolf - Canis lupus arctos '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Arthropoods - Arthropoda '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Asiatic elephant - Elephas maximus '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Atlantic puffin - Fratercula arctica '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Atlantic white-sided dolphin - Lagenorhynchus acutus '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Aye-aye - Daubentonia madagascariensis  '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Bar-headed goose - Anser indicus '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Bats - Order Chiroptera '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Beaver, American - Castor canadensis '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Birds - Class Aves '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Birds of prey - Order Falconiformes '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Bison, American - Bison bison '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Black rhinoceros - Diceros bicornis '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Black-footed ferret - Mustela nigripes '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Blue-footed booby - Sula nebouxii '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Blue whale - Balaenoptera musculus '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Bobcat - Lynx rufus '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Bottlenose dolphin - Tursiops truncatus '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Brown bear - Ursus arctos '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Burchells zebra - Equus burchellii  '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Caecilians - Order Gymnophiona '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'California sea hare - Aplysia californica '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Canada goose - Branta canadensis '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Canids - Family Canidae '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Caracal - Caracal caracal '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Caribou - Rangifer tarandus '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Carnivores - Order Carnivora '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Cartilaginous Fishes - Class Chondrichthyes '; tlos.add(tlo); tlo = new TestLookupObject__c(); 
             tlo.name = 'Cats - Family Felidae '; tlos.add(tlo); 
             tlo = new TestLookupObject__c(); tlo.name = 'Cetaceans - Order Cetacea '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Cheetah - Acinonyx jubatus '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Chordates - Phylum Chordata '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Cichlids - Family Cichlidae '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Cnidaria - Phylumn Cnidaria '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Common dolphin - Delphinus delphis '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Common seal - Phoca vitulina  '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Dugong - Dugong dugong '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Dusky dolphin - Lagenorhynchus obscurus  '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Echinoderms - Phylum Echinodermata '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Eland antelope - Tragelaphus oryx '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Elephants - Proboscidea '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Eurasian lynx - Lynx lynx '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'European common toad - Bufo bufo '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'European robin - Erithacus rubecula '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Even-toed ungulates - Order Artiodactyla  '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Firefish - Pterois volitans '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Frigatebirds - Fregatidae '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Frogs and toads - Order Anura  '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Galapagos land iguana - Conolophus subcristatus '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Galapagos tortoise - Geochelone nigra '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Gastropods, slugs and snails - Class Gastropoda '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Giant anteater - Myrmecophaga tridactyla '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Giant panda - Ailuropoda melanoleuca '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Giraffe - Giraffa camelopardalis '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Golden-crowned sifaka - Propithecus tattersalli '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Gorilla - Gorilla gorilla '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Gray whale - Eschrichtius robustus '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Great white shark - Carcharodon carcharias '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Greater flamingo - Phoenicopterus ruber '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Green poison dart frog - Dendrobates auratus '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Green sea turtle - Chelonia mydas  '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Hares, rabbits, and pikas - Order Lagomorpha '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Hawksbill sea turtle - Eretmochelys imbricata '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Herons, storks, ibises, and spoonbills - Order Ciconiiformes '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Hummingbirds - Family Trochilidae  '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Insects - Class Insecta '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Irrawaddy dolphin - Orcaella brevirostris '; tlos.add(tlo);
             tlo = new TestLookupObject__c(); tlo.name = 'Ivory-billed woodpecker - Campephilus principalis  '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Jellyfish - Class Scyphozoa  '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Koala - Phascolarctos cinereus '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Komodo Dragon - Varanus komodoensis  '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Lava lizard - Microlophus albemarlensis '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Leatherback sea turtle - Dermochelys coriacea '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Lemurs, monkeys, and apes - Order Primates '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Leopard - Panthera pardus '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Lion - Panthera leo '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Lionfish - Pterois volitans '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Lizards, Amphisbaenians, and Snakes - Order Squamata '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Loggerhead turtle - Caretta caretta  '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Mammals - Class Mammalia '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Manatees - Genus Trichechus '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Marine iguana - Amblyrhynchus cristatus '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Meerkat - Suricata suricatta '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Mollusks - Phylum Mollusca '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Monarch butterfly - Danaus plexippus '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Moose, American - Alces americanus '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Mountain Lion - Puma concolor '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Mustelids - Family Mustelidae  '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Nene goose - Branta sandvicensis '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Nine-banded armadillo - Dasypus novemcinctus '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Northern cardinal - Cardinalis cardinalis '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Northern gannet - Morus bassanus '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Northern bottlenose whale - Hyperoodon ampullatus  '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Ocelot - Leopardus pardalis '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Odd-toed ungulates - Order Perissodactyla '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Orca - Orcinus orca '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Owls - Order Strigiformes  '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Panda - Ailuropoda melanoleuca '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Panther - Panthera onca '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Pelicans and relatives - Order Pelicaniformes '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Penguins - Order Sphenisciformes '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Pigeon guillemot - Cepphus columba '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Pigs - Family Suidae '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Polar bear - Ursus maritimus '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Primates - Order Primates '; tlos.add(tlo); tlo = new TestLookupObject__c(); 
             tlo.name = 'Pronghorn - Antilocapra americana '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Przewalskis wild horse - Equus caballus przewalskii  '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Rabbits, hares, and pikas - Order Lagomorpha '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Ray-finned fishes - Class Actinopterygii '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Red-eyed tree frog - Agalychnis callidryas '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Reindeer - Rangifer tarandus '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Reptiles - Class Reptilia '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Rhinoceros, black - Diceros bicornis '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Rhinoceros, white - Ceratotherium simum '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Rhinoceros iguana - Cyclura cornuta '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Rodents - Order Rodentia '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Rodriguez flying fox - Pteropus rodricensis '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Roseate spoonbill - Platalea ajaja '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Ruby-throated hummingbird - Archilochus colubris  '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Scarlet ibis - Eudocimus ruber '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Shoebill - Balaeniceps rex '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Siberian tiger - Panthera tigris altaica '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Snails, slugs, and nudibranchs - Class Gastropoda '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Snow leopard - Panthera uncia '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Somali wild ass - Equus asinus somalicus '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Southern tamandua - Tamandua tetradactyla '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Sponges - Phylum Porifera '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Spectacled bear - Tremarctos ornatus  '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Tapirs - Family Tapiridae '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Tiger - Panthera tigris '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Tinamous - Order Tinamiformes '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Tufted titmouse - Baeolophus bicolor '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Turtles and tortoises - Order Chelonia  '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Wandering albatross - Diomedea exulans '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Waterfowl - Order Anseriformes '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'White rhinoceros - Ceratotherium simum  '; tlos.add(tlo); tlo = new TestLookupObject__c(); tlo.name = 'Xenarthrans - Order Xenarthra '; tlos.add(tlo);        
         
             insert tlos; 
             */
        
      }  
      
      public List<SelectOption> getFieldNames()
      {
                 Map<String, Schema.SObjectField> m = myObject.getSObjectType().getDescribe().fields.getMap();
                 List<String> fieldNames = new List<String>();
                 fieldNames.addAll(m.keySet());
                 List<SelectOption> fieldNamesSO = new List<SelectOption>();
                 for(String fn : fieldNames)
                     fieldNamesSO.add(new SelectOption(fn,fn));
                 return fieldNamesSO;
      }
      
      public static testMethod void testUIDemoCon() 
      {
      	
      	TestObject__c to = new TestObject__c();
      	ApexPages.StandardController sc = new ApexPages.StandardController(to);
      	UIDemoController con = new UIDemoController(sc);
      	con.getFieldNames();
      	con.save();
      	
      }
}